<template>
  <el-dialog :title="title" :visible.sync="visible" width="1300px" append-to-body>
    <div class="app-container">
      <el-table v-loading="loading" :data="tableData">
        <el-table-column width="100" label="姓名" align="center" prop="cutmName">
          <template slot-scope="scope">
            <el-input v-model="scope.row.cutmName" clearable style="width: 240px"/>
          </template>
        </el-table-column>
        <el-table-column width="110" label="联系电话" align="center" prop="mobileTelNum">
          <template slot-scope="scope">
            <el-input v-model="scope.row.mobileTelNum" clearable style="width: 240px"/>
          </template>
        </el-table-column>
        <el-table-column width="50" label="性别" align="center" prop="genderCd">
          <template slot-scope="scope">
            {{ scope.row.genderCd == 1 ? '男' : '女' }}
          </template>
        </el-table-column>
        <el-table-column width="50" label="类型" align="center" prop="ageType">
          <template slot-scope="scope">
            {{ scope.row.isNeedSign == 1 ? '成人' : '儿童' }}
          </template>
        </el-table-column>
        <el-table-column width="150" label="证件类型" align="center" prop="certiType"/>
        <el-table-column width="180" label="证件号码" align="center" prop="certiCode">
          <template slot-scope="scope">
            <el-input v-model="scope.row.certiCode" clearable style="width: 240px"/>
          </template>
        </el-table-column>
        <el-table-column label="出生日期" align="center" prop="birthday"/>
        <el-table-column label="是否需要签署" align="center" prop="isNeedSign">
          <template slot-scope="scope">
            {{ scope.row.isNeedSign == 1 ? '是' : '否' }}
          </template>
        </el-table-column>
        <el-table-column label="联系地址" align="center" prop="contractLocation">
          <template slot-scope="scope">
            <el-input v-model="scope.row.contractLocation" clearable style="width: 240px"/>
          </template>
        </el-table-column>
        <el-table-column label="备注" align="center" prop="remark">
          <template slot-scope="scope">
            <el-input v-model="scope.row.remark" clearable style="width: 240px"/>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="130">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              v-if="scope.row.isNeedSign==1"
              icon="el-icon-edit"
              @click="handecontractResend(scope.row)"
            >重发短信
            </el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="updateById(scope.row)"
            >修改信息
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </el-dialog>
</template>

<script>
import {pageList,updateById} from "@/api/salepurchase/travelperson"
import {econtractResend} from "@/api/tool/tourism"

export default {
  name: "travelperson",
  components: {},
  data() {
    return {
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      visible: false,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      tableData: [],
      ycContract:'',
      sendSms:{
        contractNumber:'',
        phone: ''
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        saleOrderId: '',
      },
    }
  },
  created() {
    this.getList()
  },
  methods: {
    open(saleOrderId,ycContract) {
      this.sendSms.contractNumber=ycContract
      this.queryParams.saleOrderId=saleOrderId
      this.visible = true
      this.title = "人员名单"
      this.getList()
    },
    getList() {
      this.loading = true
      pageList(this.queryParams).then(response => {
          this.tableData = response.rows
          this.total = response.total
          this.loading = false
        }
      )
    },
    updateById(row) {
      this.loading = true
      updateById(row).then(response => {
        this.$modal.msgSuccess("修改成功")
        this.visible = false
        this.getList()
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    handecontractResend(data) {
      this.sendSms.phone=data.mobileTelNum
      this.$modal.confirm('确认发送').then(function () {
        return econtractResend(this.sendSms)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("发送成功")
      }).catch(() => {
      })

    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
  }
}
</script>
